#!/bin/bash

help() {
  echo "Usage:"
  echo "  zcompose restart <service_name> [options...]"
}

core() {
  if [ "$1" = "" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
    help
    exit 0
  fi

  # Exit when met error
  set -e

  local service_name=$1
  # local args=${@:2}
  # service::run $service_name restart $args

  # zmicro service stop $service_name
  # zmicro service start $service_name

  # 滚动更新
  # pull latest, make it as rolling update
  service::run $service_name pull $args

  # stop
  service::run $service_name down $args
  # then start
  service::run $service_name up -d $args
}

run() {
  core $@
}

run $@
